<?php 
class HttpRequest extends CHttpRequest{
	private $_isAjaxRequest;
	private $_isFlashRequest;
	private $_urlReferrer = '';
	
	/**
	 * 加入ajax参数判断
	 * @param boolean $enableAjax 是否请用ajax判断
	 * @see CHttpRequest::getIsAjaxRequest()
	 */
	public function getIsAjaxRequest($enableAjax = true)
	{
		if($this->_isAjaxRequest === null)
			$this->_isAjaxRequest = isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH']==='XMLHttpRequest';
		return $enableAjax ? $this->getParam('ajax', $this->_isAjaxRequest) : $this->_isAjaxRequest;
	}
	
// 	public function getUrlReferrer($enableReferrer = true){
// 		if($this->_urlReferrer === ''){
// 			$referrer = !empty($_GET['referrer']) ? $_GET['referrer'] : (isset($_SERVER['HTTP_REFERER']) ? $_SERVER['HTTP_REFERER'] : null);
// 			$referrer = substr($referrer, -1) == '?' ? substr($referrer, 0, -1) : $referrer;
// 			$referrer = htmlspecialchars($referrer, ENT_QUOTES);
// 			$referrer = str_replace('&amp;', '&', $referrer);
// 			$this->_urlReferrer = strip_tags($referrer);
// 		}
// 		return $this->_urlReferrer;
// 	}
	
// 	/**
// 	 * 加入ajax参数判断
// 	 * @see CHttpRequest::getIsFlashRequest()
// 	 */
// 	public function getIsFlashRequest($enableAjax = true){
// 		if($this->_isFlashRequest === null)
// 			$this->_isFlashRequest = isset($_SERVER['HTTP_USER_AGENT']) && (stripos($_SERVER['HTTP_USER_AGENT'],'Shockwave')!==false || stripos($_SERVER['HTTP_USER_AGENT'],'Flash')!==false);;
// 		return $enableAjax ? $this->getParam('ajax', $this->_isFlashRequest) : $this->_isFlashRequest;
// 	}
}
?>